//
//  FPAlipayInfoView.m
//  FinanceProject
//
//  Created by 陈显摆 on 2025/2/24.
//

#import "FPAlipayInfoView.h"

#define row_height 794.f / 375.f * SCREEN_WIDTH

@interface FPAlipayInfoView () <UITableViewDelegate , UITableViewDataSource , UIScrollViewDelegate>

@property (nonatomic , strong) UITableView *tableView;

@end

@implementation FPAlipayInfoView

- (void)awakeFromNib {
    
    [super awakeFromNib];
    
    self.backgroundColor = UIColor.clearColor;
    
    [UIView setCornerForView:self.backView withRadius:5.f bounds:CGRectMake(0.f, 0.f, SCREEN_WIDTH, 415.f) corners:(UIRectCornerTopLeft | UIRectCornerTopRight)];
    
    self.lineView.backgroundColor = MAIN_VIEW_BACKGROUND_COLOR;
    self.openAlipayBtn.backgroundColor = MAIN_BLUE_COLOR;
    self.openAlipayBtn.clipsToBounds = YES;
    self.openAlipayBtn.layer.cornerRadius = 22.f;
    
    [self.openAlipayBtn handleViewControlEvents:UIControlEventTouchUpInside withBlock:^{
       
        self.openAlipayHandle();
    }];
    
//    self.backView.backgroundColor = UIColor.clearColor;
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0.f, 0.f, SCREEN_WIDTH, 415.f) style:(UITableViewStylePlain)];
    [self.backView addSubview:self.tableView];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.rowHeight = row_height;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    FPBaseTableViewCell *cell;
    
    if (cell == nil) {
        
        cell = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass(FPBaseTableViewCell.class) owner:nil options:nil].lastObject;
    }
    
    cell.backgroundColor = UIColor.clearColor;
    cell.contentView.backgroundColor = UIColor.clearColor;
    
    UIImageView *iv = [[UIImageView alloc] initWithFrame:CGRectMake(0.f, 0.f, SCREEN_WIDTH, row_height)];
    [cell.contentView addSubview:iv];
    iv.image = IMG(@"bg_alipay_navigate");
    
    return cell;
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    
    CGFloat offsetY = scrollView.contentOffset.y;
    
    // 最多下滑到table view 的background view的高度
    if (offsetY <= 0.f) {
        
        offsetY = 0.f;
        self.tableView.contentOffset = CGPointMake(0.f, 0.f);
    }
}




@end
	
